<%@ page import="com.sjsq.po.Book" %>
<%@ page import="com.sjsq.po.User" %>
<%@ page import="com.sjsq.service.impl.BookServiceImpl" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: ZJ X
  Date: 2020/11/27
  Time: 10:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>

    <title>查看图书</title>
    <style type="text/css">
        h1{
            text-align: center;
        }
        #before{
            text-align: center;
        }
        #head{
            background: #eeeeee;height: 80px;
        }
        #headLink{
            font-size: 20px;
        }
        #headWelLink{
            font-size: 20px;
        }
    </style>
</head>
<body>
<%--头部信 息--%>
<%
    User user =(User)session.getAttribute("user");
    if(user == null){
        response.sendRedirect("login.jsp");
    }else {
%>
<div id="head">
    <table width="100%">
        <td id="headWelLink">欢迎您：<%=user.getName()%></td>
        <td align="right" id="headLink">
            <a href="cart.jsp">我的购物车</a>
            <a href="logout.jsp">安全退出</a>
        </td>
    </table>
</div>
<%
    }
%>

<%--图书信息--%>
<%
    Book book = new Book();
    BookServiceImpl service = new BookServiceImpl();
    List<Book> list = service.select(book);
%>
<h1>图书列表</h1>
<div id="before">
    <a href="javascript: window.history.go(-1)">返回上一级</a>
</div>
<table align="center" cellpadding="10" cellspacing="10">
    <tr bgcolor="green">
        <td>编号</td>
        <td>书名</td>
        <td>价格</td>
        <td>作者</td>
        <td>封皮</td>
        <td>出版社</td>
    </tr>
    <%
        String bg = null;
        for (int i = 0;i<list.size();i++){
            Book b =list.get(i);
            if(i%2 == 0){
                bg = "pink";
            }else{
                bg = "yellow";
            }

    %>
    <tr bgcolor="<%=bg%>">
        <td><%=b.getBookid()%></td>
        <td><a href="doInfo.jsp?bookid=<%=b.getBookid()%>"><%=b.getBookname()%></a></td>
        <td><%=b.getPrice() %></td>
        <td><%=b.getAuthor() %></td>
        <td><%=b.getPicture() %></td>
        <td><%=b.getPublish() %></td>
    </tr>
    <%
        }
    %>
</table>
</body>
</html>